#include "List.h"
#include "IVisitor.h"

List::List(const ExprTypeList& elts, int ctx, int nodeId):
    exprType(nodeId),
    _elts(elts),
    _ctx(ctx)
{
}
    
List::~List()
{
    _elts.clear();
}
    
QString List::type() const
{
    return "List";
}
    

ExprTypeList List::elts()
{
    return _elts;
}

void List::setElts(const ExprTypeList& elts)
{
    _elts = elts;
}

int List::ctx()
{
    return _ctx;
}

void List::setCtx(int ctx)
{
    _ctx = ctx;
}

    
QString List::toString() const
{
    return QString("List[elts=%1, ctx=%2]").
                arg(_elts.toString()).
                arg(_ctx);
}
    
void List::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitList(node.dynamicCast<List>());
}
    
void List::traverse(IVisitor* visitor)
{
    _elts.traverse(visitor);
}